<%@ page import="com.workmanager.bean.WorkBean" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: YIJIE
  Date: 2016/8/26
  Time: 18:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../inc/top.jsp"%>
<script src="../static/assets/js/jquery-1.10.2.min.js"></script>
<script src="../static/assets/js/jPages.js"></script>
<%
    int tatolpage = 0;
    List<WorkBean> works = null;
    if(request.getAttribute("allmywork")!=null) {
        works = (List<WorkBean>) request.getAttribute("allmywork");
        tatolpage = 0;
        if ((works.size() % 5 == 0)) {
            tatolpage = works.size() / 5;
        } else {
            tatolpage = ((works.size() / 5) + 1);
        }
    }
    StudentBean astudent=(StudentBean) request.getSession().getAttribute("学生");
%>
<div class="king-page-box">
    <div class="king-container clearfix">
        <div class="ui-ui" style="position: relative; z-index: 0;">
            <div class="panel panel-default mb0">
                <div class="panel-heading">
                    <span style="font-size: 16px;font-weight:bolder;">我的所有作业</span>
                </div>
                <% if(astudent.getClass_id()!=null){%>
                <div class="panel-body">
                    <div class="king-wrapper clearfix">
                        <div>
                            <div class="col-lg-10">
                                <label style="font-weight:bolder;">班级布置作业次数: ${jobtasknum}</label>
                            </div>
                            <div class="col-lg-2" align="right">
                            <a href="/project/student/homePage.jsp">返回</a>
                            </div>
                            <div class="col-lg-10">
                                <label style="font-weight:bolder;">我已提交作业次数: ${myworknum}</label>
                            </div>
                        </div>
                    </div>
                </div>
                <form name="historyWork" method="post" id="historyWork">
                    <div id="demo">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>作业编号</th>
                                <th>作业名称</th>
                                <th>上交时间</th>
                                <th>评价</th>
                            </tr>
                            </thead>
                            <tbody id="datas">
                            <c:forEach items="${allmywork}" var="mywork">
                                                <tr>
                                                    <td>${mywork.jobTask_id}</td>
                                                    <td><a href="<%=ctxpath%>/teacherWorkController/download.wm?workId=${mywork.work_id}">${mywork.aJobTask.jobTask_title}</a></td>
                                                    <td>${mywork.work_date}</td>
                                                    <td>
                                                        <a  href="<%=ctxpath%>/talk/talk.jsp?stu&id=${mywork.work_id}">查看</a>
                                                    </td>
                                                </tr>
                                            </c:forEach>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="5">
                                    <div class="pull-right king-page-box">
                                        <p class="pull-left mt15">共<span id="total"><%=works.size()%></span>条记录，当前第<span id="cur_page">1</span>/<span id="total_page">3</span>页</p>
                                        <div class="holder pull-right ml15">
                                            <div class="king-jP">
                                                <a class="jp-previous jp-disabled">«</a>
                                                <a class="jp-current">1</a>
                                                <span class="jp-hidden">...</span>
                                                <a href="#" class="">2</a>
                                                <span class="jp-hidden">...</span>
                                                <a><%=tatolpage%></a>
                                                <a class="jp-next">»</a>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </form>
                <%}else{%>
                <h3>你还没有班级和老师哦~</h3>
                <%}%>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $("#toptitle").html("我的所有作业");
    })
    // 设置分页
    $("#demo .holder").jPages({
        containerID : "datas",
        previous : "«",
        next : "»",
        perPage : 5,
        delay : 10,
        callback: function(pages, items){
            $('#total').text(items.count);
            $('#cur_page').text(pages.current);
            $('#total_page').text(pages.count);
        }
    });
</script>
<%@include file="../inc/bottom.jsp"%>
